var reg = /^[a-zA-Z0-9_]{4,6}$/

var str = 'admin123'   //来自用户的输入

var r = reg.test(str)

if(r == true){
    console.log('用户允许注册')
}else {
    console.log('用户名不合法')
}

//0357-1234567

var reg1 = /^[0-9]{4}-[0-9]{7}$/

var phone = '0352-1817234'

var result = reg1.test(phone)

if(result != true){
    console.log('电话号不符合要求，请重新输入')
}else {
    console.log('电话号符合要求')
}



